<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>文档碎片优化</title>
</head>
<body>
  <script>
  
   for (var i = 10; i; i --){
     var op = document.createElement("p");
     op.innerHTML = i
     document.body.appendChild(op)
   }
  
  const fragEle = document.createDocumentFragment()
  for (var i = 5; i; i --){
     var op = document.createElement("p");
     op.innerHTML = i
     fragEle.appendChild(op)
   }
   document.body.appendChild(fragEle)





  </script>
</body>
</html>